package example.plugins.automaton;

import framework.automaton.Logic;
import framework.automaton.plugin.AutomatonPlugin;
import framework.grid.Grid;
import framework.grid.Location;

/**
 * Example implementation of the automaton plugin for the framework. Implements
 * Conway's game of life (live/dead States, rules involving neighbors).
 * This class initializes the necessary objects, in accordance with the
 * AutomatonPluginInterface.
 * @author Bill Ge, May Zhai, Alex Yoo
 *
 */
public class ConwayAutomatonPlugin extends AutomatonPlugin{
	/**variable to store the automata plugin to be used*/
	Logic logic;
	/**variable to store the Grid that will be used to hold the model*/
	Grid grid;

	/**
	 * Initializes concrete Logic object.
	 */
	public Logic getLogic() {
		logic = new ConwayLogic();
		return logic;
	}

	/**
	 * Creates initial grid.
	 */
	public Grid getInitialGrid() {
		grid = new SquareGrid(20);
		ConwayState live = new ConwayState(Constants.ALIVE);
		ConwayState dead = new ConwayState(Constants.DEAD);
		
		for(int i = 0; i <grid.getNumRows(); i++){
			for(int j = 0; j<grid.getNumCols(); j++){
				grid.put(new Location(i,j),dead);
			}
		}
		
		grid.put(new Location(5,5),live);
		grid.put(new Location(5,6),live);
		grid.put(new Location(5,7),live);
		
		return grid;
	}
}